package com.yunfangdata.service.impl;


import com.yunfangdata.domain.Officialstu;
import com.yunfangdata.mapper.OfficialstuMapper;
import com.yunfangdata.query.OfficialstuQueryObject;
import com.yunfangdata.query.QueryObject;
import com.yunfangdata.service.IOfficialstuService;
import com.yunfangdata.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class OfficialstuServiceImpl implements IOfficialstuService{
    
    @Autowired
    private OfficialstuMapper mapper;
    @Override
    public void save(Officialstu entity) {
        mapper.insert(entity);
    }

    @Override
    public void delete(Long id) {
        mapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(Officialstu entity) {
        mapper.updateByPrimaryKey(entity);
    }

    @Override
    public Officialstu get(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Officialstu> list() {
        return mapper.selectAll();
    }

    @Override
    public PageResult query(OfficialstuQueryObject qo) {
        int total = mapper.queryForCount(qo);

        if (total==0){
            return new PageResult();
        }
        List<Officialstu> list = mapper.queryForList(qo);

        return new PageResult(total,list);
    }

    @Override
    public void leave(Long id) {
        mapper.leave(id);
    }

}